package com.codeplex.tdmg4mc;

import java.io.File;

import net.minecraft.client.Minecraft;
import net.minecraftforge.client.IItemRenderer;
import net.minecraftforge.client.MinecraftForgeClient;
import net.minecraftforge.common.config.Configuration;

import org.lwjgl.input.Keyboard;

import api.player.render.RenderPlayerAPI;
import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

@SideOnly(Side.CLIENT)
public class TDMGClientProxy extends TDMGCommonProxy
{
	public static ModelGear modelGear;
	
	@Override
	public void init(Configuration config)
	{
		TDMG.isClient=true;
		modelGear=new ModelGear();
		TDMGKeyInput.leftKey=new Key(config.get(TDMG.KEYS, "left.key", Keyboard.getKeyName(Keyboard.KEY_A)).getString(),
				config.get(TDMG.KEYS, "left.shift", true).getBoolean(true), config.get(TDMG.KEYS, "left.ctrl", false).getBoolean(false),
				config.get(TDMG.KEYS, "left.alt", false).getBoolean(false));
		TDMGKeyInput.rightKey=new Key(config.get(TDMG.KEYS, "right.key", Keyboard.getKeyName(Keyboard.KEY_D)).getString(),
				config.get(TDMG.KEYS, "right.shift", true).getBoolean(true), config.get(TDMG.KEYS, "right.ctrl", false).getBoolean(false),
				config.get(TDMG.KEYS, "right.alt", false).getBoolean(false));
		TDMGKeyInput.shootKey=new Key(config.get(TDMG.KEYS, "both.shoot.key", Keyboard.getKeyName(Keyboard.KEY_W)).getString(),
				config.get(TDMG.KEYS, "both.shoot.shift", true).getBoolean(true), config.get(TDMG.KEYS, "both.shoot.ctrl", false).getBoolean(false),
				config.get(TDMG.KEYS, "both.shoot.alt", false).getBoolean(false));
		TDMGKeyInput.removeKey=new Key(config.get(TDMG.KEYS, "both.remove.key", Keyboard.getKeyName(Keyboard.KEY_S)).getString(),
				config.get(TDMG.KEYS, "both.remove.shift", true).getBoolean(true), config.get(TDMG.KEYS, "both.remove.ctrl", false).getBoolean(false),
				config.get(TDMG.KEYS, "both.remove.alt", false).getBoolean(false));
		TDMGKeyInput.boostKey=new Key(config.get(TDMG.KEYS, "boost.key", Keyboard.getKeyName(Keyboard.KEY_SPACE)).getString(),
				config.get(TDMG.KEYS, "boost.shift", true).getBoolean(true), config.get(TDMG.KEYS, "boost.ctrl", false).getBoolean(false),
				config.get(TDMG.KEYS, "boost.alt", false).getBoolean(false));
		TDMGKeyInput.autoKey=new Key(config.get(TDMG.KEYS, "auto.key", Keyboard.getKeyName(Keyboard.KEY_Z)).getString(),
				config.get(TDMG.KEYS, "auto.shift", true).getBoolean(true), config.get(TDMG.KEYS, "auto.ctrl", false).getBoolean(false),
				config.get(TDMG.KEYS, "auto.alt", false).getBoolean(false));
		TDMGKeyInput.autoToggle=config.get(Configuration.CATEGORY_GENERAL, "auto.toggle", true).getBoolean(true);
		RenderingRegistry.registerEntityRenderingHandler(EntityGearHook.class, new RenderGearHook());
		MinecraftForgeClient.registerItemRenderer(TDMG.dualSword, (IItemRenderer)TDMG.dualSword);
		RenderPlayerAPI.register(TDMG.NAME, TDMGRenderPlayer.class);
	}
	
	@Override
	public Configuration getConfig()
	{
		return new Configuration(new File(Minecraft.getMinecraft().mcDataDir, "config/TDMG.cfg"), true);
	}
	
	@Override
	public int addArmor(String name)
	{
		return RenderingRegistry.addNewArmourRendererPrefix(name);
	}
}
